#pragma once

#include "packet.h"

class heart_beat : public packet
{
	public:
		heart_beat( );
		~heart_beat(void);
		void init( MemoryPool<heart_beat, 1000, 0, boost::function<heart_beat*(void)> > *p, uint32_t src, uint32_t dst, char *_id, uint64_t _up, uint64_t _down, uint64_t _maxup, uint64_t _maxdown, uint64_t _free_space, uint64_t _used_space,
					uint64_t _c_in, uint64_t _c_out, uint64_t _mc_in, uint64_t _mc_out, uint64_t _avg_lat );
		char *serialize();
		Packet_Type getType() const { return _type; }

		const char *getId() { return id; }

		void print();

		void destroy() { if( pool ) pool->destroy( this ); }

		static uint32_t PACKET_HEARTBEAT_ID_LEN;
		static uint32_t PACKET_HEARTBEAT_SIZE;

	private:

		char id[41];

		/*
			Bytes / sec (network)
		*/
		uint64_t up;
		uint64_t down;
		uint64_t maxup;
		uint64_t maxdown;

		/*
			Bytes (hdd)
		*/
		uint64_t free_space;
		uint64_t used_space;

		/*
			Connection stats
		*/
		uint64_t connections_in;
		uint64_t connections_out;
		uint64_t max_connections_in;
		uint64_t max_connections_out;
		uint64_t average_latency;

		MemoryPool<heart_beat, 1000, 0, boost::function<heart_beat *(void)> > *pool;
};

